﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

#endregion

namespace Sebarf.Core.Interfaces {
	/// <summary>
	/// Description of the class
	/// </summary>
	public abstract class RequestHandler<Type> : IRequestHandler where Type : class {
		#region Public Methods

		protected abstract object OnProcessRequest(Type request, IServiceLocatorService serviceLocator);

		#endregion

		#region IRequestHandler Members

		public bool CanHandleRequest(IRequest request) {
			if (request == null) {
				return false;
			}
			return typeof(Type).IsAssignableFrom(request.GetType());
		}

		public object ProcessRequest(IRequest request, IServiceLocatorService serviceLocator) {
			return OnProcessRequest(request as Type, serviceLocator);
		}

		#endregion
	}
}